const app = getApp()
Page({

  data: {
    userInfo: {},
    background: ['../../images/pic1.jpg', '../../images/pic2.jpg', '../../images/pic3.jpg'],
    vertical: false,
  },
  onLoad: function (options) {
    // this.setData({
    //   userInfo: app.globalData.userInfo
    // })
  },
  myScanCode: function() {
    const that = this
    wx.scanCode({
      complete: (res) => { },
      fail: (res) => {
        wx.showToast({
          title: '扫码失败',
          icon: 'none',
          duration: 1500
        })
      },
      onlyFromCamera: true,
      scanType: ['qrCode'],
      success: (result) => {
        console.log(result.result)
        wx.request({
          url: app.globalData.serverUrl + '/user/' + result.result,
          method: 'get',
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          data: {
            skey: app.globalData.userInfo.skey,
          },
          success: function (res) {
            if (res.data.status == 200) {
              console.log(res)
              console.log(res.data.data)
              app.globalData.checkedUserInfo = res.data.data
              console.log(app.globalData.checkedUserInfo)
              wx.redirectTo({
                url: '/pages/checkinfo/checkinfo',
              })
            } else {
              wx.showToast({
                title: '服务器异常',
                icon: 'none',
                duration: 1500
              })
            }
          },
          fail: function (error) {
            //调用服务端登录接口失败
            wx.showToast({
              title: '请确保网络通畅',
              icon: 'none',
              duration: 1500
            })
          }
        })
      },
    })

  },
  myQrcode() {
    wx.navigateTo({
      url: '/pages/home-client/home-client',
    })
  }
  
})